home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
Resources
/
Chat & Communication
/
Digsby build 37
/
digsby_setup.exe
/
lib
/
msn
/
MSNObject.pyo
(
.txt
)
< prev
next >
Wrap
Python Compiled Bytecode
|
2008-10-13
|
6KB
|
157 lines
# Source Generated with Decompyle++
# File: in.pyo (Python 2.5)
import hashlib
import util
import msn
from logging import getLogger
log = getLogger('msn.object')
class MSNObject(object):
__slots__ = 'creator size type location friendly sha1d sha1c\n _friendly _sha1d _sha1c stamp _stamp contenttype contentid avatarid\n avatarcontentid _avatarcontentid _xml'.split()
EUF = '{A4268EEC-FEC5-49E5-95C3-F126696BDBF6}'
types = {
'2': 'emoticons',
'3': 'icon',
'5': 'bg_image',
'8': 'wink',
'11': 'sound',
'12': 'state' }
def __init__(self, Creator, Type, Location, Size, SHA1D, Friendly = u'\x00', SHA1C = None, contenttype = None, contentid = None, stamp = None, avatarid = None, avatarcontentid = None):
object.__init__(self)
self.creator = Creator
self.type = Type
self.size = Size
self.location = Location
self._sha1d = SHA1D
self._friendly = Friendly
if not SHA1C:
pass
self._sha1c = self.calc_sha1c()
self._stamp = stamp
self._avatarcontentid = avatarcontentid
self.contenttype = contenttype
self.contentid = contentid
self.avatarid = avatarid
self._xml = None
def get_sha1d(self):
return self._sha1d.encode('base-64').strip()
def set_sha1d(self, new_val):
self._sha1d = new_val.decode('base-64')
def get_friendly(self):
return self._friendly.encode('utf-16-le').encode('base-64').strip()
def set_friendly(self, new_val):
self._friendly = new_val.decode('base-64').decode('utf-16-le')
def calc_sha1c(self):
to_hash = 'Creator%sSize%sType%sLocation%sFriendly%sSHA1D%s' % (self.creator, self.size, self.type, self.location, self.friendly, self.sha1d)
return hashlib.sha1(to_hash).digest()
def get_sha1c(self):
return self.calc_sha1c().encode('base-64').strip()
def set_sha1c(self, new_val):
if new_val != self.sha1c:
raise ValueError, 'SHA1C hash is not correct'
def get_stamp(self):
return None if self._stamp is None else self._stamp.encode('base-64').strip()
def set_stamp(self, new_val):
if new_val is None:
self._stamp = None
else:
self._stamp = new_val.decode('base-64')
def get_avatarcontentid(self):
return None if self._avatarcontentid is None else msn.util.base64_encode(self._avatarcontentid)
def set_avatarcontentid(self, new_val):
if new_val is None:
self._avatarcontentid = None
else:
self._avatarcontentid = msn.util.base64_decode(new_val)
friendly = property(get_friendly, set_friendly)
sha1d = property(get_sha1d, set_sha1d)
sha1c = property(get_sha1c, set_sha1c)
stamp = property(get_stamp, set_stamp)
avatarcontentid = property(get_avatarcontentid, set_avatarcontentid)
def to_xml(self):
if self._xml is None:
t = util.tag('msnobj')
t._attrs = util.odict()
t._attrs['Creator'] = self.creator
t._attrs['Size'] = self.size
t._attrs['Type'] = self.type
t._attrs['Location'] = self.location
t._attrs['Friendly'] = self.friendly
t._attrs['SHA1D'] = self.sha1d
t._attrs['SHA1C'] = self.sha1c
xml = t._to_xml(pretty = False).strip()
xml = xml[:-3] + '/>'
self._xml = xml
return self._xml
def __ne__(self, other):
return not self.__eq__(other)
def __eq__(self, other):
try:
for attr in ('creator', 'size', 'type', 'location', 'sha1d'):
mine = getattr(self, attr)
theirs = getattr(other, attr)
if getattr(self, attr) != getattr(other, attr):
return False
continue
except AttributeError:
e = None
return False
return True
def parse(cls, xml):
t = util.tag(xml)
o = cls(**t._attrs)
o.stamp = t._attrs.get('stamp', None)
o.avatarcontentid = t._attrs.get('avatarcontentid', None)
(o.friendly, o.sha1d) = [ t[k] for k in [
'Friendly',
'SHA1D'] ]
try:
o.sha1c = t['SHA1C']
except:
[]
[]
o.sha1c = o.sha1c
o._xml = xml
return o
parse = classmethod(parse)